home *** CD-ROM | disk | FTP | other *** search
- Path: stern.fokus.gmd.de!news
- From: Watson <sayegh@fokus.gmd.de>
- Newsgroups: comp.lang.c
- Subject: Re: To malloc (new) or not to malloc? When is the question.
- Date: Tue, 09 Jan 1996 17:54:32 +0100
- Organization: GMD FOKUS - Research Institute for Open Communication Systems
- Message-ID: <30F29DC8.49C@fokus.gmd.de>
- References: <4ctvk3$ort@maverick.tad.eds.com>
- NNTP-Posting-Host: pollux.fokus.gmd.de
- Mime-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- X-Mailer: Mozilla 2.0b4 (X11; I; SunOS 5.4 sun4m)
-
- Darrin Smith wrote:
-
- > struct st1{char one[10];
- > char two[20];
- > char three[10];
- > };
- > st1 *sptr; //or struct st1 *sptr in C instead of C++
- > sptr=fread(....);
- > This caused a program I was trying to debug to crash. When I allocated
- > memory for sptr (I used sptr=new st1; but I suppose malloc would have done
- > just as well) it worked fine.
-
- fread() does not *return* the data but the size of the data. sptr has
- to be given as a parameter.
- --
- * Greetinx,
- Watson (sayegh@fokus.gmd.de)
- more personal details at:
- http://www.fokus.gmd.de/ovma/employees/sayegh/entry.html
-